package com.example.demo.mapper;


import com.example.demo.identity.Group;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GroupMapper {


    //    检查是否存在相同的群聊信息     也可以用来查询群聊信息
    @Select("select * from groups where group_id = #{groupId}")
    List<Group> findGroupByGroupId(@Param("groupId") String groupId);

    //    创建群聊
    @Insert("insert into groups(group_id, group_name, group_leader, create_at, group_type, group_avatar) values(" +
            "#{group_id}, #{group_name}, #{group_leader}, #{create_at}, #{group_type}, #{group_avatar})")
    int createGroup(Group group);


    //    通过groupId获取群聊信息
    @Select("select * from groups where group_id = #{groupId}")
    Group findGroupById(@Param("groupId") String groupId);


}
